home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Online / Apache / include / apache / http_core.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-06  |  10.9 KB  |  321 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  *
  54.  * Portions of this software are based upon public domain software
  55.  * originally written at the National Center for Supercomputing Applications,
  56.  * University of Illinois, Urbana-Champaign.
  57.  */
  58.  
  59. #ifndef APACHE_HTTP_CORE_H
  60. #define APACHE_HTTP_CORE_H
  61.  
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif
  65.  
  66. /*****************************************************************
  67.  *
  68.  * The most basic server code is encapsulated in a single module
  69.  * known as the core, which is just *barely* functional enough to
  70.  * serve documents, though not terribly well.
  71.  *
  72.  * Largely for NCSA back-compatibility reasons, the core needs to
  73.  * make pieces of its config structures available to other modules.
  74.  * The accessors are declared here, along with the interpretation
  75.  * of one of them (allow_options).
  76.  */
  77.  
  78. #define OPT_NONE 0
  79. #define OPT_INDEXES 1
  80. #define OPT_INCLUDES 2
  81. #define OPT_SYM_LINKS 4
  82. #define OPT_EXECCGI 8
  83. #define OPT_UNSET 16
  84. #define OPT_INCNOEXEC 32
  85. #define OPT_SYM_OWNER 64
  86. #define OPT_MULTI 128
  87. #define OPT_ALL (OPT_INDEXES|OPT_INCLUDES|OPT_SYM_LINKS|OPT_EXECCGI)
  88.  
  89. /* options for get_remote_host() */
  90. /* REMOTE_HOST returns the hostname, or NULL if the hostname
  91.  * lookup fails.  It will force a DNS lookup according to the
  92.  * HostnameLookups setting.
  93.  */
  94. #define REMOTE_HOST (0)
  95.  
  96. /* REMOTE_NAME returns the hostname, or the dotted quad if the
  97.  * hostname lookup fails.  It will force a DNS lookup according
  98.  * to the HostnameLookups setting.
  99.  */
  100. #define REMOTE_NAME (1)
  101.  
  102. /* REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
  103.  * never forced.
  104.  */
  105. #define REMOTE_NOLOOKUP (2)
  106.  
  107. /* REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
  108.  * a double reverse lookup, regardless of the HostnameLookups
  109.  * setting.  The result is the (double reverse checked) hostname,
  110.  * or NULL if any of the lookups fail.
  111.  */
  112. #define REMOTE_DOUBLE_REV (3)
  113.  
  114. #define SATISFY_ALL 0
  115. #define SATISFY_ANY 1
  116. #define SATISFY_NOSPEC 2
  117.  
  118. API_EXPORT(int) ap_allow_options (request_rec *);
  119. API_EXPORT(int) ap_allow_overrides (request_rec *);
  120. API_EXPORT(const char *) ap_default_type (request_rec *);     
  121. API_EXPORT(const char *) ap_document_root (request_rec *); /* Don't use this!  If your request went
  122.                       * through a Userdir, or something like
  123.                       * that, it'll screw you.  But it's
  124.                       * back-compatible...
  125.                       */
  126. API_EXPORT(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type);
  127. API_EXPORT(const char *) ap_get_remote_logname(request_rec *r);
  128.  
  129. /* Used for constructing self-referencing URLs, and things like SERVER_PORT,
  130.  * and SERVER_NAME.
  131.  */
  132. API_EXPORT(char *) ap_construct_url(pool *p, const char *uri, request_rec *r);
  133. API_EXPORT(const char *) ap_get_server_name(request_rec *r);
  134. API_EXPORT(unsigned) ap_get_server_port(const request_rec *r);
  135. API_EXPORT(unsigned long) ap_get_limit_req_body(const request_rec *r);
  136. API_EXPORT(void) ap_custom_response(request_rec *r, int status, char *string);
  137. API_EXPORT(int) ap_exists_config_define(char *name);
  138.  
  139. /* Authentication stuff.  This is one of the places where compatibility
  140.  * with the old config files *really* hurts; they don't discriminate at
  141.  * all between different authentication schemes, meaning that we need
  142.  * to maintain common state for all of them in the core, and make it
  143.  * available to the other modules through interfaces.
  144.  */
  145.     
  146. typedef struct {
  147.     int method_mask;
  148.     char *requirement;
  149. } require_line;
  150.      
  151. API_EXPORT(const char *) ap_auth_type (request_rec *);
  152. API_EXPORT(const char *) ap_auth_name (request_rec *);     
  153. API_EXPORT(int) ap_satisfies (request_rec *r);
  154. API_EXPORT(const array_header *) ap_requires (request_rec *);    
  155.  
  156. #ifdef WIN32
  157. /* 
  158.  * CGI Script stuff for Win32...
  159.  */
  160. typedef enum { eFileTypeUNKNOWN, eFileTypeBIN, eFileTypeEXE16, eFileTypeEXE32, 
  161.                eFileTypeSCRIPT } file_type_e;
  162. typedef enum { INTERPRETER_SOURCE_UNSET, INTERPRETER_SOURCE_REGISTRY, 
  163.                INTERPRETER_SOURCE_SHEBANG } interpreter_source_e;
  164. API_EXPORT(file_type_e) ap_get_win32_interpreter(const request_rec *, char **);
  165. #endif
  166.  
  167. #ifdef CORE_PRIVATE
  168.  
  169. /*
  170.  * Core is also unlike other modules in being implemented in more than
  171.  * one file... so, data structures are declared here, even though most of
  172.  * the code that cares really is in http_core.c.  Also, another accessor.
  173.  */
  174.  
  175. char *ap_response_code_string (request_rec *r, int error_index);
  176.  
  177. extern API_VAR_EXPORT module core_module;
  178.  
  179. /* Per-directory configuration */
  180.  
  181. typedef unsigned char allow_options_t;
  182. typedef unsigned char overrides_t;
  183.  
  184. typedef struct {
  185.     /* path of the directory/regex/etc.  see also d_is_fnmatch below */
  186.     char *d;
  187.     /* the number of slashes in d */
  188.     unsigned d_components;
  189.  
  190.     /* If (opts & OPT_UNSET) then no absolute assignment to options has
  191.      * been made.
  192.      * invariant: (opts_add & opts_remove) == 0
  193.      * Which said another way means that the last relative (options + or -)
  194.      * assignment made to each bit is recorded in exactly one of opts_add
  195.      * or opts_remove.
  196.      */
  197.     allow_options_t opts;
  198.     allow_options_t opts_add;
  199.     allow_options_t opts_remove;
  200.     overrides_t override;
  201.     
  202.     /* MIME typing --- the core doesn't do anything at all with this,
  203.      * but it does know what to slap on a request for a document which
  204.      * goes untyped by other mechanisms before it slips out the door...
  205.      */
  206.     
  207.     char *ap_default_type;
  208.   
  209.     /* Authentication stuff.  Groan... */
  210.     
  211.     int satisfy;
  212.     char *ap_auth_type;
  213.     char *ap_auth_name;
  214.     array_header *ap_requires;
  215.  
  216.     /* Custom response config. These can contain text or a URL to redirect to.
  217.      * if response_code_strings is NULL then there are none in the config,
  218.      * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES.
  219.      * This lets us do quick merges in merge_core_dir_configs().
  220.      */
  221.   
  222.     char **response_code_strings;
  223.  
  224.     /* Hostname resolution etc */
  225. #define HOSTNAME_LOOKUP_OFF    0
  226. #define HOSTNAME_LOOKUP_ON    1
  227. #define HOSTNAME_LOOKUP_DOUBLE    2
  228. #define HOSTNAME_LOOKUP_UNSET    3
  229.     unsigned int hostname_lookups : 4;
  230.  
  231.     signed int do_rfc1413 : 2;   /* See if client is advertising a username? */
  232.  
  233.     signed int content_md5 : 2;  /* calculate Content-MD5? */
  234.  
  235. #define USE_CANONICAL_NAME_OFF   (0)
  236. #define USE_CANONICAL_NAME_ON    (1)
  237. #define USE_CANONICAL_NAME_DNS   (2)
  238. #define USE_CANONICAL_NAME_UNSET (3)
  239.     unsigned use_canonical_name : 2;
  240.  
  241.     /* since is_fnmatch(conf->d) was being called so frequently in
  242.      * directory_walk() and its relatives, this field was created and
  243.      * is set to the result of that call.
  244.      */
  245.     unsigned d_is_fnmatch : 1;
  246.  
  247.     /* should we force a charset on any outgoing parameterless content-type?
  248.      * if so, which charset?
  249.      */
  250. #define ADD_DEFAULT_CHARSET_OFF   (0)
  251. #define ADD_DEFAULT_CHARSET_ON    (1)
  252. #define ADD_DEFAULT_CHARSET_UNSET (2)
  253.     unsigned add_default_charset : 2;
  254.     char *add_default_charset_name;
  255.  
  256.     /* System Resource Control */
  257. #ifdef RLIMIT_CPU
  258.     struct rlimit *limit_cpu;
  259. #endif
  260. #if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
  261.     struct rlimit *limit_mem;
  262. #endif
  263. #ifdef RLIMIT_NPROC
  264.     struct rlimit *limit_nproc;
  265. #endif
  266.     unsigned long limit_req_body;  /* limit on bytes in request msg body */
  267.  
  268.     /* logging options */
  269.     enum { srv_sig_unset, srv_sig_off, srv_sig_on,
  270.         srv_sig_withmail } server_signature;
  271.     int loglevel;
  272.     
  273.     /* Access control */
  274.     array_header *sec;
  275.     regex_t *r;
  276.  
  277. #ifdef WIN32
  278.     /* Where to find interpreter to run scripts */
  279.     interpreter_source_e script_interpreter_source;
  280. #endif    
  281.     
  282. } core_dir_config;
  283.  
  284. /* Per-server core configuration */
  285.  
  286. typedef struct {
  287.   
  288. #ifdef GPROF
  289.     char *gprof_dir;
  290. #endif
  291.  
  292.     /* Name translations --- we want the core to be able to do *something*
  293.      * so it's at least a minimally functional web server on its own (and
  294.      * can be tested that way).  But let's keep it to the bare minimum:
  295.      */
  296.     char *ap_document_root;
  297.   
  298.     /* Access control */
  299.  
  300.     char *access_name;
  301.     array_header *sec;
  302.     array_header *sec_url;
  303. } core_server_config;
  304.  
  305. /* for http_config.c */
  306. void ap_core_reorder_directories(pool *, server_rec *);
  307.  
  308. /* for mod_perl */
  309. CORE_EXPORT(void) ap_add_per_dir_conf (server_rec *s, void *dir_config);
  310. CORE_EXPORT(void) ap_add_per_url_conf (server_rec *s, void *url_config);
  311. CORE_EXPORT(void) ap_add_file_conf(core_dir_config *conf, void *url_config);
  312. CORE_EXPORT_NONSTD(const char *) ap_limit_section (cmd_parms *cmd, void *dummy, const char *arg);
  313.  
  314. #endif
  315.  
  316. #ifdef __cplusplus
  317. }
  318. #endif
  319.  
  320. #endif    /* !APACHE_HTTP_CORE_H */
  321.